import { Body, Controller, Post } from '@nestjs/common';
import { MenuManageService } from './menuManage.service';
import { CreateMenuDto } from './dto/create.dto';
import { UpdateMenuDto } from './dto/update.dto';
import { MenuManage } from './entities/menuManage.entity';
import { DeleteMenuDto } from './dto/delete.dto';

@Controller('menu')
export class MenuManageController {
  constructor(private readonly menuManageService: MenuManageService) {}

  @Post('create')
  async createMenu(@Body() createMenuDto: CreateMenuDto) {
    return await this.menuManageService.createMenu(createMenuDto);
  }

  @Post('delete')
  async deleteMenu(@Body() deleteMenuDto: DeleteMenuDto) {
    return await this.menuManageService.deleteMenu(deleteMenuDto);
  }

  @Post('update')
  async updateMenu(@Body() updateMenuDto: UpdateMenuDto) {
    return await this.menuManageService.updateMenu(updateMenuDto);
  }

  @Post('detail')
  async getDetail(@Body() params: Partial<MenuManage>) {
    return await this.menuManageService.getDetail(params);
  }

  @Post('tree')
  async getMenuList() {
    return await this.menuManageService.getMenuTree();
  }
}
